﻿import QtQuick 2.5
import QtGraphicalEffects 1.0

import "../../js/UI.js" as Style
import "../common"
import "../../js/util.js" as Util
Item  {
    property alias m_source: image.source
    property alias nameText: textnameid.text
    property var colorText: ""
    property alias nameTextpoint: textnameid.font.pointSize
    property alias m_nameText: textnameid
    property bool p_cache: true
    property bool isCallImage: false    // 显示灰色头像
    Image {
        id: image
        sourceSize: Qt.size(mask.width,mask.width)
        smooth:true
        visible: false
        onStatusChanged: {
            if(status == Image.Error)
                source = "qrc:/images/gray_head.png"
        }
        cache:p_cache
    }
    Rectangle{
        id: mask
        anchors.fill: parent
        radius: height/2
        visible: false
    }
    OpacityMask{
        id:m_opacityMask
        anchors.fill: parent
        source: image
        maskSource: mask
        visible: (image.source != ""&&image.status!=Image.Error && image.source != "qrc:/images/gray_head.png") || isCallImage
    }
    Rectangle{
        anchors.fill: parent
        radius: height/2
        height:width
        border.color: Style.TitleColor
        border.width: 2
        color: "#fafafa"
        visible: !m_opacityMask.visible
        AText{
            anchors.centerIn: parent
            text: nameText.substring(0,1)
            font.pixelSize: parent.width * 0.4
            color: Style.TitleColor
            elide: Text.ElideRight
        }
        AText{
            id: textnameid
            visible: false
        }
    }
}


